﻿CREATE PROCEDURE [dbo].[proc_Roles_Create]
	(
		@RoleName nvarchar(50),
		@Description nvarchar(256),
		@Sort int,
		@FAdminFlg bit,
		@AppActions nvarchar(2000)
	)
AS
begin
	Insert Into aspnet_Roles(RoleName,Description,Sort,FAdminFlg)Values(@RoleName,@Description,@Sort,@FAdminFlg)
	declare @RoleId int
	Set @RoleId=(Select @@Identity)
	
	Declare @i int
	Set @i=0
	while(@i<len(@AppActions))
	begin
	Insert Into RoleGroupAppList(RoleId,SysAppId)Values(@RoleId, substring(@AppActions,@i,charindex(',',@AppActions,@i)-@i))
	Set @i=charindex(',',@AppActions,@i)+1
	end
end
	RETURN
